import pandas as pd
import mplfinance as mpf
import talib

df = pd.read_csv('./files/test02.csv')
df = df[['trade_time', 'open', 'close', 'high', 'low', 'vol']]
df.columns = ['trade_time', 'Open', 'Close', 'High', 'Low', 'Volume']
df['trade_time'] = pd.to_datetime(df['trade_time'])
df.set_index('trade_time', inplace=True)

df['upper'], df['middle'], df['lower'] = talib.BBANDS(df['Close'], timeperiod=20, nbdevup=2, nbdevdn=2, matype=0)

# """
# make_marketcolors() 设置k线颜色
# :up 设置阳线柱填充颜色
# :down 设置阴线柱填充颜色
# ：edge 设置蜡烛线边缘颜色 'i' 代表继承k线的颜色
# ：wick 设置蜡烛上下影线的颜色
# ：volume 设置成交量颜色
# ：inherit 是否继承, 如果设置了继承inherit=True，那么edge即便设了颜色也会无效
# """
my_color = mpf.make_marketcolors(up='cyan', down='red', edge='black', wick='black', volume='blue')


add_plot = mpf.make_addplot(df[['lower']])
mpf.plot(df, addplot=add_plot, type='candle', mav=(2, 5, 10), volume=True)



